package cn.aiweiyi.qingjing.coupon.distribution;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.web.client.RestTemplate;

/**
 * @author 青衿
 * @Date 2020/11/19 8:25
 * 分发服务启动类
 **/
@SpringBootApplication(scanBasePackages = {"cn.aiweiyi.qingjing.coupon"})  //作为SpringBoot启动器
@EnableFeignClients     //作为Feign客户端,调用其他微服务
@EnableEurekaClient     //作为Eureka客户端
@EnableCircuitBreaker   //作为引入断路器Hystrix(熔断、降级)
@EnableJpaAuditing      //引入JPA审计,给某些字段赋默认值
public class DistributionApplication {
    //RestTemplate是Spring提供的发起REST HTTP调用
    @Bean
    @LoadBalanced
    //Ribbon以负载均衡的方式进行调用,开启负载均衡策略
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(DistributionApplication.class, args);
    }
}
